<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'newPwd.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<script src="jquery/js/jquery-1.8.2.js"></script>
		<script src="jquery/js/jquery-ui-1.8.23.custom.js"></script>

		<link rel="stylesheet"
			href="jquery/css/ui-lightness/jquery-ui-1.9.0.custom.css" />
		<link rel="stylesheet" type="text/css"
			href="/webbei/js/bgjs/css/index.css" />
		<link rel="stylesheet" type="text/css" href="css/custom.css" />
		<link rel="stylesheet" type="text/css" href="css/login.css" />


		<link rel="Stylesheet" type="text/css" href="inc/wColorPicker.css" />
		<script type="text/javascript" src="inc/wColorPicker.js"></script>
		<script type="text/javascript" src="js/login.js"></script>
		<script type="text/javascript" src="js/bgjs/js/script.js"></script>
		
		<link href="css/login.css" type="text/css" rel="stylesheet" />
	<script>
	$().ready(function(){
	  var key = $("#key").val();
	  var urlKey = $("#urlKey").val();
	  if(urlKey==key){
	    $("#div2").css("display","block");
	    $("#div1").css("display","none");
	  }else{
	    $("#div1").css("display","block");
	    $("#div2").css("display","none");
	  }
	});
			function updatepwd(){
				var email=$("#email").val();
				if($("#newpwd").val()==""||$("#newpwd").val()==null){
					alert("新密码不能为空");
				}else{
					if($("#newpwd").val()!=$("#pwdagain").val()){
						alert("2次密码不一致");
						$("#pwdagain").val("");
					}else{
						$.post("UpdataPwdByEmailAction",{"email":email,"password":$("#newpwd").val()},function(data){
							if(data=="success"){
								alert("修改成功");
								window.location.href=$("#path").val()+"/login.jsp"; 
							}else{
								alert("修改失败");
								$("#newpwd").val("");
								$("#pwdagain").val("");
							}
						});
				    }
				}
			}
	</script>
  </head>
  
  <body style="width: 105%;margin-left:-20px;">
  <jsp:include page="top.jsp"></jsp:include>
  <h1>密码修改</h1>
    <div align="center" style="display:none;margin-top:40px;height:480px;" id="div1">
         链接地址过期，请点击<a href="findpwd.jsp">这里</a>重新激活
    </div>
  	<div align="center" style="display: none;height:480px;" id="div2">
    		新的密码：<input type="password" id="newpwd"><br/>
    		再输一次：<input type="password" id="pwdagain"><br/>
    		<input type="button" value="修改" onclick="updatepwd()">
    		<input type="hidden" value="<%=request.getParameter("email")%>" id="email">
    		<input type="hidden" value="<%=request.getContextPath()%>" id="path">
    		<input type="hidden" value="${key }" id="key">
    		<input type="hidden" value="<%=request.getParameter("key")%>" id="urlKey">
    </div>
    <jsp:include page="bottom.jsp"></jsp:include>
  </body>
</html>
